<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <a-form-model ref="form" :model="model" slot="detail">
      <a-row>
        <a-col :span="24">
          <!--<a-form-model-item label="SQL" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="strsql">-->
            <a-input v-model="model.strsql" type="textarea" :rows="10" placeholder="请输入SQL"  ></a-input>
          <!--</a-form-model-item>-->
        </a-col>
      </a-row>
      </a-form-model>
      <a-row>
        <a-button class="outLogin" @click="goExec" type="primary" >提交</a-button>
      </a-row>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :dataSource="dataSource"
        :columns="columns"
        class="j-table-force-nowrap"
        >



      </a-table>
    </div>


  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  //import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { httpAction, getAction } from '@/api/manage'

  export default {
    name: 'query',
    //mixins:[JeecgListMixin, mixinDevice],
    mixins:[ mixinDevice],
    components: {

    },
    data () {
      return {
        model:{
          strsql:null
        },
        description: 'sql语句存放表管理页面',
        // 表头
        columns: [],
        dataSource:[],
        url: {
          execsql: "/check/execsqlCheckStrsql/execsql",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      goExec(){
        let httpurl = this.url.execsql;
        let method = 'post';
        const that = this;
        httpAction(httpurl,this.model,method).then((res)=>{
          if(res.success){
            this.columns = res.result.collist;
            this.dataSource = res.result.list||res.result;
            that.$message.success(res.message);
            that.$emit('ok');
          }else{
            that.$message.warning(res.message);
          }
        }).finally(() => {
          that.confirmLoading = false;
        })

      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .outLogin{
    //width: 36px;
    //height:36px;
    //float: right;
    margin-top: 30px;
    margin-bottom: 30px;
    margin-left: 50%;
  }
</style>